package com.xkcoding.task.job;

import jdk.internal.dynalink.beans.StaticClass;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.springframework.beans.BeanUtils;

import java.sql.SQLOutput;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author: xuchao
 * @Description:
 * @Date: 2021/2/10 11:06
 */
public class TaskThread {
    public static void main(String[] args) {
        ScheduledExecutorService SCHEDULER = new ScheduledThreadPoolExecutor(1,new BasicThreadFactory.Builder().namingPattern("redisLock-schedule-pool").daemon(true).build());

        SCHEDULER.scheduleAtFixedRate(() -> {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
                System.out.print(sdf.format(new Date()) + " 开始执行, ");
                Thread.sleep(3000);//3s
                System.out.println(sdf.format(new Date()) + "结束执行 ================");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }, 0,  2, TimeUnit.SECONDS);
        Integer integer =null;
        try {
             integer = 10;
        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }
        System.out.println(integer);


    }






}
